// eslint-disable-next-line
import { UserLayout, BasicLayout, BlankLayout } from '@/layouts'
import * as Icons from '@/core/icons'

const RouteView = {
  name: 'RouteView',
  render: h => h('router-view')
}

/**
 * 路由配置说明：
 * 建议：sider menu 请不要超过三级菜单，若超过三级菜单，则应该设计为顶部主菜单 配合左侧次级菜单
// {
//   redirect: noredirect,  //重定向
//   name: 'router-name',   //路由名称
//   hidden: true,          //可以在菜单中不展示这个路由，包括子路由。效果可以查看 other 下的路由配置。
//   isHideChildren: true,  // 折叠三级子菜单
//   meta: {
//     title: 'title',      //菜单项名称
//     icon: 'a-icon',      //菜单项图标
//     keepAlive: true,     //缓存页面
//     permission：[string]   //用来配置这个路由的权限，如果配置了将会验证当前用户的权限，并决定是否展示 *（默认情况下）
//   }
// }
 **/
export const asyncRouterMap = [
  {
    path: '/',
    name: 'root',
    component: BasicLayout,
    children: [
      // 后台首页
      // {
      //   path: '/index',
      //   name: 'index',
      //   component: () => import(/* webpackChunkName: "index" */ '@/views/page/Index'),
      //   meta: { title: '首页', keepAlive: true, icon: Icons.home, permission: ['/index'] },
      //   activePath: ['/page/create', '/page/update']
      // },

      {
        path: '/index',
        name: 'index',
        component: RouteView,
        redirect: '/page/index',
        meta: { title: '页面管理', keepAlive: true, icon: Icons.home, permission: ['/page'] },
        children: [
          {
            path: '/page/index',
            component: () => import(/* webpackChunkName: "page" */ '@/views/page/Index'),
            meta: { title: '页面设计', keepAlive: false, permission: ['/page/index'] },
            // 访问其他页面时激活该菜单(router-link-active)
            activePath: ['/page/create', '/page/update']
          },
          {
            path: '/page/create',
            component: () => import(/* webpackChunkName: "page" */ '@/views/page/Create'),
            meta: { title: '新增页面', keepAlive: false, permission: ['/page/create'] },
            hidden: true
          },
          {
            path: '/page/update',
            component: () => import(/* webpackChunkName: "page" */ '@/views/page/Update'),
            meta: { title: '编辑页面', keepAlive: false, permission: ['/page/update'] },
            hidden: true
          },
          {
            path: '/page/category',
            component: () => import(/* webpackChunkName: "page" */ '@/views/page/category/Index'),
            meta: { title: '分类模板', keepAlive: false, permission: ['/page/category'] }
          }
        ]
      },

      // 客户端
      {
        path: '/client',
        name: 'client',
        component: RouteView,
        meta: {
          title: '客户端',
          keepAlive: true,
          icon: Icons.mpweixin,
          iconStyle: { fontSize: '17.2px', color: '#36b313' },
          permission: ['/client']
        },
        children: [
          {
            path: '/client/register',
            component: () => import(/* webpackChunkName: "client" */ '@/views/client/Register'),
            meta: { title: '注册设置', keepAlive: false, permission: ['/client/register'] }
          },
          {
            path: '/client/wxapp',
            component: RouteView,
            redirect: '/client/wxapp/setting',
            meta: { title: '微信小程序', keepAlive: false, permission: ['/client/wxapp'] },
            children: [
              {
                path: '/client/wxapp/setting',
                component: () => import(/* webpackChunkName: "client" */ '@/views/client/wxapp/Setting'),
                meta: { title: '小程序设置', keepAlive: false, permission: ['/client/wxapp/setting'] }
              }
            ]
          },
          {
            path: '/client/wxofficial',
            component: RouteView,
            redirect: '/client/wxofficial/setting',
            meta: { title: '微信公众号', keepAlive: false, permission: ['/client/wxofficial'] },
            children: [
              {
                path: '/client/wxofficial/setting',
                component: () => import(/* webpackChunkName: "client" */ '@/views/client/wxofficial/Setting'),
                meta: { title: '公众号设置', keepAlive: false, permission: ['/client/wxofficial/setting'] }
              }
            ]
          },
          {
            path: '/client/h5',
            component: RouteView,
            redirect: '/client/h5/setting',
            meta: { title: 'H5端', keepAlive: false, permission: ['/client/h5'] },
            children: [
              {
                path: '/client/h5/setting',
                component: () => import(/* webpackChunkName: "client" */ '@/views/client/h5/Setting'),
                meta: { title: '站点设置', keepAlive: false, permission: ['/client/h5/setting'] }
              }
            ]
          }
        ]
      }
    ]
  },

  // 更新账户信息
  // {
  //   name: 'renew',
  //   path: '/manage',
  //   redirect: '/manage/renew',
  //   component: BasicLayout,
  //   hidden: true,
  //   meta: { title: '更新账户信息', keepAlive: false },
  //   children: [
  //     {
  //       path: 'renew',
  //       component: () => import(/* webpackChunkName: "manage" */ '@/views/manage/renew')
  //     }
  //   ]
  // },

  {
    path: '*',
    redirect: '/404',
    hidden: true
  }
]

/**
 * 基础路由
 * @type { *[] }
 */
export const constantRouterMap = [
  // 用户登录页
  {
    path: '/passport',
    component: UserLayout,
    redirect: '/passport/login',
    hidden: true,
    children: [
      {
        path: 'login',
        name: 'login',
        component: () => import(/* webpackChunkName: "passport" */ '@/views/passport/Login')
      }
    ]
  },

  // 404页
  {
    path: '/404',
    component: () => import(/* webpackChunkName: "exception" */ '@/views/exception/404')
  }
]
